package com.shawn.example.mvvmdemo.home.repository

import com.jetpack.mvvm.lib.net.ServiceCreators
import com.jetpack.mvvm.lib.net.module.HttpApiResult
import com.shawn.example.mvvmdemo.home.model.ArticleData
import com.shawn.example.mvvmdemo.home.model.ArticleDetail
import com.shawn.example.mvvmdemo.home.model.Banner
import com.shawn.example.mvvmdemo.home.net.api.HomeApiService
import dagger.hilt.android.scopes.ActivityRetainedScoped
import javax.inject.Inject

@ActivityRetainedScoped
class HomeRepository @Inject constructor() {
    private val service = ServiceCreators.create(HomeApiService::class.java)

    suspend fun getBanners(): HttpApiResult<List<Banner>> {
        return service.getBanners()
    }

    suspend fun getTopArticles(): HttpApiResult<List<ArticleDetail>> {
        return service.getTopArticles()
    }

    suspend fun getArticles(pageNum: Int): HttpApiResult<ArticleData> {
        return service.getArticles(pageNum)
    }
}